package com.dominator.api.service.impl;

import com.dominator.api.common.wrapper.Dto;
import com.dominator.api.enums.ReqEnums;
import com.dominator.api.service.EmailService;
import com.dominator.api.utils.api.ApiMessage;
import com.dominator.api.utils.exception.ApiException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class EmailServiceImpl implements EmailService {

//    @Value("${spring.mail.username}")
//    private String emailFrom;

    @Autowired
    private JavaMailSender mailSender;


    @Override
    public ApiMessage sendRegist(Dto dto) throws ApiException {
        SimpleMailMessage message = new SimpleMailMessage();
     //   message.setFrom(emailFrom);
        message.setTo(dto.getString("email"));
        message.setSubject(dto.getString("title"));
        message.setText(dto.getString("content"));
        mailSender.send(message);
        return new ApiMessage(ReqEnums.REQ_SUCCESS);
    }

    @Override
    public ApiMessage sendFindPassword(Dto dto) throws ApiException {
        return null;
    }

    @Override
    public ApiMessage sendNotice(Dto dto) throws ApiException {
        return null;
    }
}
